<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频中心 - 观看您喜爱的视频</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            min-height: 100vh;
        }
        .navbar {
            background: rgba(255, 255, 255, 0.9) !important;
            backdrop-filter: blur(10px);
            border-bottom: 1px solid #e0e0e0;
        }
        .video-card {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 16px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            overflow: hidden;
            margin-bottom: 20px;
        }
        .video-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
        }
        .video-thumbnail {
            height: 200px;
            object-fit: cover;
            width: 100%;
        }
        .video-title {
            font-weight: 600;
            color: #333;
            margin-bottom: 8px;
        }
        .play-button {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(255, 165, 0, 0.8);
            color: white;
            width: 70px;
            height: 70px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            opacity: 0;
            transition: all 0.3s ease;
        }
        .video-card:hover .play-button {
            opacity: 1;
        }
        .upload-section {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 16px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            padding: 40px 30px;
            margin-bottom: 40px;
        }
        .upload-btn {
            background: #667eea;
            color: white;
            border-radius: 8px;
            padding: 12px 25px;
            font-weight: 600;
            transition: all 0.3s ease;
        }
        .upload-btn:hover {
            background: #5a67d8;
            transform: translateY(-2px);
        }
        .file-input-container {
            position: relative;
            overflow: hidden;
            margin-top: 10px;
        }
        .file-input-container input[type=file] {
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0;
            width: 100%;
            height: 100%;
            cursor: pointer;
        }
        .file-input-label {
            display: inline-block;
            padding: 8px 16px;
            background: #f8f9fa;
            border-radius: 4px;
            font-size: 0.9rem;
            color: #495057;
        }
        .footer {
            background: rgba(255, 255, 255, 0.8);
            backdrop-filter: blur(10px);
            padding: 30px 0;
            margin-top: 40px;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light">
        <div class="container">
            <a class="navbar-brand d-flex align-items-center" href="#">
                <i class="fas fa-video me-2"></i>
                <span class="fw-bold">视频中心</span>
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link active" href="#">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">关于</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">联系</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 英雄区域 -->
    <section class="py-5 text-center">
        <div class="container">
            <h1 class="display-4 fw-bold mb-3">发现精彩视频</h1>
            <p class="lead text-muted mb-4">随时随地观看您喜爱的视频。高质量播放，流畅性能。</p>
            <a href="#videos" class="btn btn-warning btn-lg px-5 py-3 shadow-sm">
                <i class="fas fa-play me-2"></i> 开始观看
            </a>
        </div>
    </section>

    <!-- 上传区域 -->
    <section id="upload" class="py-5">
        <div class="container">
            <h2 class="text-center mb-4">上传新视频</h2>
            <p class="text-center text-muted mb-5">将您的视频添加到收藏中</p>

            <!-- 上传表单 -->
            <div class="upload-section mx-auto" style="max-width: 600px;">
                <form action="/upload" method="post" enctype="multipart/form-data">
                    <div class="mb-3">
                        <label for="videoFile" class="form-label">选择视频文件 (.mp4)</label>
                        <div class="file-input-container">
                            <input type="file" id="videoFile" name="video_file" accept="video/mp4" required>
                            <span class="file-input-label">选择文件</span>
                        </div>
                    </div>
                    <button type="submit" class="btn upload-btn w-100">
                        <i class="fas fa-upload me-2"></i> 上传视频
                    </button>
                </form>
            </div>
        </div>
    </section>

    <!-- 视频画廊 -->
    <section id="videos" class="py-5">
        <div class="container">
            <h2 class="text-center mb-4">可用视频</h2>
            <p class="text-center text-muted mb-5">从我们的高质量视频收藏中选择</p>

            <!-- 视频网格 -->
            <div class="row g-4">
                {% for video in videos %}
                <div class="col-md-6 col-lg-4">
                    <div class="video-card position-relative">
                        <img src="{{ get_video_thumbnail(video) or '/static/images/video-placeholder.jpg' }}" alt="{{ video }}" class="video-thumbnail">
                        <a href="/play/{{ video }}" class="play-button">
                            <i class="fas fa-play"></i>
                        </a>
                        <div class="p-3">
                            <h5 class="video-title">{{ video }}</h5>
                            <small class="text-muted">
                                <i class="far fa-clock me-1"></i> {{ get_video_duration(video) }}
                            </small>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>

            <!-- 无视频提示 -->
            {% if not videos %}
            <div class="text-center py-5">
                <i class="fas fa-video fa-3x text-muted mb-3"></i>
                <h4 class="mb-2">暂无视频</h4>
                <p class="text-muted">请将 .mp4 文件添加到 static/videos 目录中。</p>
            </div>
            {% endif %}
        </div>
    </section>

    <!-- 页脚 -->
    <footer class="footer">
        <div class="container text-center">
            <p class="mb-0">&copy; 2025 视频中心。保留所有权利。</p>
        </div>
    </footer>

    <!-- Bootstrap JS和依赖项 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>